﻿<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<script runat="server">

    void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        RegisterRoutes(RouteTable.Routes);
        clsAutoStart.fncAutoStartOn();
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.Ignore("{resource}.axd/{*pathInfo}");
        routes.Ignore("robots.txt");
        routes.Ignore("sitemap");
        routes.Ignore("sitemap.gz");
        routes.Ignore("sitemap.xml");
        routes.Ignore("sitemap.xml.gz");
        routes.Ignore("google_sitemap.xml");
        routes.Ignore("google_sitemap.xml.gz");
        routes.Ignore("favicon.ico");
        routes.Ignore("images/{*pathInfo}");
        routes.Ignore("Scripts/{*pathInfo}");
        routes.Ignore("Styles/{*pathInfo}");
        //-----------------------------------------------------------------------------------------------------------------
        routes.MapPageRoute("client"
            , "{userControl}/{param1}/{param2}/{param3}/{param4}/{param5}"
            , "~/default.aspx"
            , true
            , new RouteValueDictionary { 
            { "userControl", "index" } 
            ,{ "param1", "" }
            ,{ "param2", "" }
            ,{ "param3", "" }
            ,{ "param4", "" }
            ,{ "param5", "" }
            });
    }
    
    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown

    }
        
    void Application_Error(object sender, EventArgs e) 
    { 
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e) 
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }

    void Application_BeginRequest(object sender, EventArgs e)
    {
        //HttpApplication app = sender as HttpApplication;
        //if (app != null)
        //{
        //    string domain = "nato.vn";
        //    string host = app.Request.Url.Host.ToLower();
        //    string path = app.Request.Url.PathAndQuery;
        //    if (!String.Equals(host, domain))
        //    {
        //        Uri newURL = new Uri(app.Request.Url.Scheme +
        //        "://" + domain + path);
        //        app.Context.Response.RedirectPermanent(
        //        newURL.ToString(), endResponse: true);
        //    }
        //}
    }
       
</script>
